/* GUI CONVERTED from rwrorp04.p (converter v1.75) Mon Oct 30 14:39:52 2000 */
/* rwrorp04.p - ROUTING OPERATION COST REPORT                           */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/*F0PN*/ /*K0ZW*/
/*V8:ConvertMode=FullGUIReport                                 */
/* REVISION: 7.3        LAST MODIFIED: 02/18/93     BY: emb *G701*      */
/* REVISION: 7.3        LAST MODIFIED: 04/05/93     BY: emb *G701*      */
/* REVISION: 7.3        LAST MODIFIED: 01/16/95     by: srk *G0C1*      */
/* REVISION: 7.3        LAST MODIFIED: 02/06/95     by: cpp *G0DL*      */
/*                                     04/19/95     by: srk *G0L1*      */
/* REVISION: 8.6        LAST MODIFIED: 12/17/97     by: bvm *K0ZW*      */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane */
/* REVISION: 8.6E     LAST MODIFIED: 07/23/98   BY: *J2TK* Thomas Fernandes */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* myb              */
/* REVISION: 9.1      LAST MODIFIED: 08/24/00   BY: *N0NM* Arul Victoria    */
/* REVISION: 9.1      LAST MODIFIED: 10/27/00   BY: *N0TF* Katie Hilbert    */


/*GUI global preprocessor directive settings */
&GLOBAL-DEFINE PP_PGM_RP TRUE
&GLOBAL-DEFINE PP_ENV_GUI TRUE


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

     {mfdtitle.i "b+ "} /*G701*/

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE rwrorp04_p_1 "Show Alternate Routings"
/* MaxLen: Comment: */

&SCOPED-DEFINE rwrorp04_p_2 "Cum Total"
/* MaxLen: Comment: */

&SCOPED-DEFINE rwrorp04_p_3 "Op Total"
/* MaxLen: Comment: */


/* ********** End Translatable Strings Definitions ********* */

/*N0NM* ------------------- BEGIN DELETE ----------------------- *
 * &SCOPED-DEFINE rwrorp04_p_4 "* Routing/Operation Deleted. Rerun Operation Cost Calculation."
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rwrorp04_p_5 "(Cont.)"
 * /* MaxLen: Comment: */
 *
 * /*J2TK*/ /* THIRD PARAMETER OF mfmsg03.i CHANGED FROM "inventory"  */
 *          /* TO "Inventory"                                         */
 * &SCOPED-DEFINE rwrorp04_p_6 ""Inventory""
 * /* MaxLen: 9 Comment: */
 *
 *N0NM* ------------------- END   DELETE ----------------------- */

/*N0NM*/ define variable  c-footer-msg as character format "x(66)" no-undo.
     define variable part1 like pt_part no-undo.
     define variable part2 like pt_part no-undo.
     define variable part_type like pt_part_type no-undo.
     define variable show-alts like mfc_logical initial true
        label {&rwrorp04_p_1} no-undo.

     define variable site like si_site no-undo.
     define variable csset like sct_sim no-undo.

     define variable method as character format "x(15)" no-undo.
     define variable cum_yield as decimal no-undo.

     define variable routing like ro_routing no-undo.
     define variable bom_code like pt_bom_code no-undo.
     define variable default-routing like ro_routing no-undo.
     define variable default-bom_code like pt_bom_code no-undo.
     define variable gl_set like icc_gl_set no-undo.
/*G0DL*/ define variable no_routing_indic as character format "x(1)" no-undo.

     
/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
        
 RECT-FRAME       AT ROW 1.4 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1   COLUMN 3 NO-LABEL
 SKIP(.1)  /*GUI*/
site           colon 25 si_desc no-label
        csset          colon 25 cs_desc no-label
        method         no-label
        skip(1)
        part1          colon 25
        part2          label {t001.i}
        skip (1)
        part_type      colon 30
        show-alts      colon 30
      SKIP(.4)  /*GUI*/
with frame a side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER.
 F-a-title = &IF (DEFINED(SELECTION_CRITERIA) = 0)
  &THEN " Selection Criteria "
  &ELSE {&SELECTION_CRITERIA}
  &ENDIF .
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:WIDTH-PIXELS in frame a =
  FONT-TABLE:GET-TEXT-WIDTH-PIXELS(
  RECT-FRAME-LABEL:SCREEN-VALUE in frame a + " ", RECT-FRAME-LABEL:FONT).
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5. /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



     /* SET EXTERNAL LABELS */
     setFrameLabels(frame a:handle).

     site = global_site.

     find first icc_ctrl no-lock no-error.
     if not available icc_ctrl then do:
/*J2TK** {mfmsg03.i 533 4 ""inventory"" """" """"}  */

/*N0NM* /*J2TK*/ {mfmsg03.i 533 4 {&rwrorp04_p_6} """" """"} */
/*N0NM*/     { pxmsg.i
          &MSGNUM = 533
          &ERRORLEVEL = 4
          &MSGARG1 = getTermLabel(""INVENTORY"",9)
        }

/*G0C1*  repeat:
 *             if batchrun = no then pause.
 *             leave.
 *          end.
 *G0C1*/
/*G0C1*/    if batchrun = no then
/*K0ZW*/        if c-application-mode <> 'web' then pause.
         undo, leave.
     end.
/*G0L1*/ assign
        gl_set = icc_gl_set
        csset = gl_set.

     find si_mstr no-lock where si_site = site no-error.
     if available si_mstr then do:
        display site si_desc with frame a.
        if si_gl_set > "" then csset = si_gl_set.
     end.

     display csset with frame a.
     find cs_mstr where cs_set = csset no-lock no-error.
     method = "".
     if available cs_mstr then do:
        method = "[ " + cs_method + " / " + cs_type + " ]".
        display cs_desc method with frame a.
     end.
     else display "" @ cs_desc method with frame a.

     display site part1 part2 part_type
     with frame a.

/*K0ZW*/ {wbrp01.i}

     
/*GUI*/ {mfguirpa.i true  "printer" 132 }

/*GUI repeat : */
/*GUI*/ procedure p-enable-ui:


        if part2 = hi_char then part2 = "".

/*G0C1*/    

           
run p-action-fields (input "display").
run p-action-fields (input "enable").
end procedure. /* p-enable-ui, replacement of Data-Entry GUI*/

/*GUI*/ procedure p-report-quote:


           find si_mstr where si_site = site no-lock no-error.
           if not available si_mstr then do:
          {mfmsg.i 708 3} /*SITE DOES NOT EXIST*/
/*K0ZW*/          if c-application-mode = 'web' then return.
          /*GUI NEXT-PROMPT removed */
          /*GUI UNDO removed */ RETURN ERROR.
           end.

           display si_desc with frame a.

           if si_db <> global_db then do:
          {mfmsg.i 5421 3} /*SITE IS NOT ASSIGNED TO THIS DATABASE*/
/*K0ZW*/          if c-application-mode = 'web' then return.
          /*GUI NEXT-PROMPT removed */
          /*GUI UNDO removed */ RETURN ERROR.
           end.

           find cs_mstr where cs_set = csset no-lock no-error.
           method = "".
           if available cs_mstr then do:
          method = "[ " + cs_method + " / " + cs_type + " ]".
          display cs_desc method with frame a.
           end.
           else display "" @ cs_desc method with frame a.

           if csset = "" then do:
          {mfmsg.i 40 3}  /*BLANK NOT ALLOWED*/
/*K0ZW*/          if c-application-mode = 'web' then return.
          /*GUI NEXT-PROMPT removed */
          /*GUI UNDO removed */ RETURN ERROR.
           end.

           find cs_mstr where cs_set = csset no-lock no-error.
           if not available cs_mstr then do:
          {mfmsg.i 5407 3} /*COST SET DOES NOT EXIST*/
/*K0ZW*/          if c-application-mode = 'web' then return.
          /*GUI NEXT-PROMPT removed */
          /*GUI UNDO removed */ RETURN ERROR.
           end.
/*K0ZW*   end. */

/*K0ZW*/ if (c-application-mode <> 'web') or
/*K0ZW*/    (c-application-mode = 'web' and
/*K0ZW*/    (c-web-request begins 'data')) then do:

        bcdparm = "".
/*G0L1*
 *          {mfquoter.i site}
 *          {mfquoter.i csset}
 *          {mfquoter.i part1}
 *          {mfquoter.i part2}
 *          {mfquoter.i part_type}
 *          {mfquoter.i show-alts}
 *G0L1*/
/*G0L1*/    {gprun.i ""gpquote.p""
             "(input-output bcdparm,
                    6,
                    string(site),
                    string(csset),
                    string(part1),
                    string(part2),
                    string(part_type),
                    string(show-alts),
                    null_char,
                    null_char,
                    null_char,
                    null_char,
                    null_char,
                    null_char,
                    null_char,
                    null_char,
                    null_char,
                    null_char,
                    null_char,
                    null_char,
                    null_char,
                    null_char)"
        }

        if part2 = "" then part2 = hi_char.

        global_site = site.

/*K0ZW*/ end.

        
/*GUI*/ end procedure. /* p-report-quote */
/*GUI - Field Trigger Section */

/*GUI MFSELxxx removed*/
/*GUI*/ procedure p-report:
/*GUI*/   {gpprtrpa.i  "printer" 132}
/*GUI*/   mainloop: do on error undo, return error on endkey undo, return error:
find first icc_ctrl no-lock no-error.
find si_mstr no-lock where si_site = site no-error.
find cs_mstr where cs_set = csset no-lock no-error.
find si_mstr where si_site = site no-lock no-error.
find cs_mstr where cs_set = csset no-lock no-error.
find cs_mstr where cs_set = csset no-lock no-error.




        {mfphead.i}

/*G0DL*/    FORM /*GUI*/ 
/*N0NM* /*G0DL*/    {&rwrorp04_p_4}   */
/*N0NM*/    c-footer-msg no-label
/*G0DL*/    with STREAM-IO /*GUI*/  frame pfoot page-bottom
/*K0ZW*/    width 132.

/*N0NM* ------------------- BEGIN ADD ----------------------- */
         { pxmsg.i
          &MSGNUM = 3658
          &MSGBUFFER = c-footer-msg
        }
            c-footer-msg = "* " + c-footer-msg + ".".
/*N0NM* ------------------- END   ADD ----------------------- */

/*N0NM* ------------------- BEGIN DELETE ----------------------- *
 *          /* SET EXTERNAL LABELS */
 *          setFrameLabels(frame pfoot:handle).
 *N0NM* ------------------- END   DELETE ----------------------- */

/*G0DL*/    view frame pfoot.

        FORM /*GUI*/ 
           si_site colon 12 si_desc no-label
           csset colon 12 cs_desc no-label space(5) method no-label
        with STREAM-IO /*GUI*/  frame pheader side-labels width 132 no-attr-space page-top.

        /* SET EXTERNAL LABELS */
        setFrameLabels(frame pheader:handle).

        display si_site si_desc csset cs_desc method
        with frame pheader STREAM-IO /*GUI*/ .

        for each pt_mstr no-lock
        where pt_part >= part1 and pt_part <= part2
        and (part_type = "" or part_type = pt_part_type):

           
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/


/*G0L1*/       assign
          routing = pt_part
          bom_code = pt_part.

           find ptp_det no-lock where ptp_part = pt_part
           and ptp_site = site no-error.
           if available ptp_det then do:
          if ptp_routing <> "" then routing = ptp_routing.
          if ptp_bom_code <> "" then bom_code = ptp_bom_code.
           end.
           else do:
          if pt_routing > "" then routing = pt_routing.
          if pt_bom_code > "" then bom_code = pt_bom_code.
           end.

/*G0L1*/       assign
          default-routing = routing
          default-bom_code = bom_code.

           for each iro_det no-lock where iro_part = bom_code
           and iro_site = site
           and iro_cost_set = csset
           and iro_routing = routing
           break by iro_routing by iro_part
           by iro_site by iro_cost_set by iro_op
/*N0TF*           with frame c width 132 no-attr-space:      */
/*N0TF*/   with frame c width 132 no-attr-space down:

          /* SET EXTERNAL LABELS */
          setFrameLabels(frame c:handle).
          
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/


          do with frame b:
             /* SET EXTERNAL LABELS */
             setFrameLabels(frame b:handle).
      if first-of (iro_routing) then do:
/*G0DL*              if page-size - line-counter < 6 then page. */
/*G0DL*/             if page-size - line-counter < 8 then page.
             display pt_part pt_desc1 no-label pt_desc2 no-label
            with frame b side-labels width 132 STREAM-IO /*GUI*/ .

             display space(13)
            iro_routing @ routing
            iro_part @ bom_code
            "" @ iro_op
/*G0DL*/                "" @ no_routing_indic
             with frame c STREAM-IO /*GUI*/ .

             if iro_mtl_ll <> 0 then
             display iro_mtl_ll @ iro_mtl_tl format "->>>,>>9.99<<<"
             with frame c STREAM-IO /*GUI*/ .
             if iro_mtl_ll <> 0 then down 1 with frame c.
          end.

/*G0DL*           if page-size - line-counter < 0 then do: */
/*G0DL*/          if page-size - line-counter < 2 then do:
             page.
             display pt_part
/*N0NM*         {&rwrorp04_p_5} @ pt_desc1 no-label  */
/*N0NM*/        ("(" + getTermLabel("CONTINUED",22) + ")")  @ pt_desc1 no-label
            with frame b side-labels width 132 STREAM-IO /*GUI*/ .
          end.
         end. /* do with */

/*G0DL*  FIND ROUTING DETAIL CORRESPONDING TO ITEM ROUTING COST RECORD       */
/*G0DL*  IF NOT AVAILABLE PRINT * IN NO_ROUTING_INDIC FIELD ON THE REPORT  */
/*G0DL*/          find last ro_det no-lock
/*G0DL*/          where ro_routing = iro_routing
/*G0DL*/          and ro_op   = iro_op  no-error.
/*G0DL*/          if available ro_det
/*G0DL*/          then no_routing_indic = " ".
/*G0DL*/          else no_routing_indic = "*".

          display iro_op
/*N0TF* /*G0DL*/ no_routing_indic format "x(1)" column-label " "  */
/*N0TF*/     no_routing_indic format "x(1)" no-label
             iro_mtl_tl format "->>>,>>9.99<<<"
             iro_lbr_tl format "->>>,>>9.99<<<"
             iro_bdn_tl format "->>>,>>9.99<<<"
             iro_sub_tl format "->>>,>>9.99<<<"
             iro_mtl_tl + iro_lbr_tl + iro_bdn_tl + iro_sub_tl
            @ iro_value01
              format "->>>,>>9.99<<<" column-label {&rwrorp04_p_3}
             iro_cost_tot
              format "->>>,>>9.99<<<" column-label {&rwrorp04_p_2} WITH STREAM-IO /*GUI*/ .
           end.

           if show-alts then do:
          for each ptr_det no-lock where ptr_part = pt_part
          and ptr_site = site
          and (ptr_routing <> default-routing
           or ptr_bom_code <> default-bom_code):

             
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/


             for each iro_det no-lock
             where iro_part = (if ptr_bom_code > "" then ptr_bom_code
            else ptr_part)
             and iro_site = site
             and iro_cost_set = csset
             and iro_routing = (if ptr_routing > "" then ptr_routing
            else ptr_part)
             break by iro_routing by iro_part
             by iro_site by iro_cost_set by iro_op
/*N0TF*             with frame e width 132 no-attr-space:     */
/*N0TF*/     with frame e width 132 no-attr-space down:

            /* SET EXTERNAL LABELS */
            setFrameLabels(frame e:handle).
            
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/


          do with frame d:
            /* SET EXTERNAL LABELS */
            setFrameLabels(frame d:handle).
        if first-of (iro_routing) then do:

/*G0DL*                    if page-size - line-counter < 6 then do: */
/*G0DL*/                   if page-size - line-counter < 8 then do:
                  page.
                  display pt_part
/*N0NM*              {&rwrorp04_p_5}  no-label  */
/*N0NM*/      ("(" + getTermLabel("CONTINUED",22) + ")") format "x(24)" no-label
                 with frame d side-labels width 132 STREAM-IO /*GUI*/ .
               end.

               display space(13)
                  iro_routing @ routing
                  iro_part @ bom_code
                  "" @ iro_op
/*G0DL*/                      "" @ no_routing_indic
               with frame e STREAM-IO /*GUI*/ .

               if iro_mtl_ll <> 0 then display
                  iro_mtl_ll @ iro_mtl_tl format "->>>,>>9.99<<<"
               with frame e STREAM-IO /*GUI*/ .
               if iro_mtl_ll <> 0 then down 1 with frame e.
            end.

/*G0DL*                 if page-size - line-counter < 0 then do: */
/*G0DL*/                if page-size - line-counter < 2 then do:
               page.
               display pt_part
/*N0NM*              {&rwrorp04_p_5}  no-label  */
/*N0NM*/    ("(" + getTermLabel("CONTINUED",22) + ")") format "x(24)"  no-label
                  with frame d side-labels width 132 STREAM-IO /*GUI*/ .
            end.
          end. /* do with */

/*G0DL*  FIND ROUTING DETAIL CORRESPONDING TO ITEM ROUTING COST RECORD       */
/*G0DL*  IF NOT AVAILABLE PRINT * IN NO_ROUTING_INDIC FIELD ON THE REPORT  */
/*G0DL*/                find last ro_det no-lock
/*G0DL*/                where ro_routing = iro_routing
/*G0DL*/                and ro_op = iro_op  no-error.
/*G0DL*/                if available ro_det
/*G0DL*/                then no_routing_indic = " ".
/*G0DL*/                else no_routing_indic = "*".

            display iro_op
/*N0TF* /*G0DL*/   no_routing_indic format "x(1)" column-label " "  */
/*N0TF*/       no_routing_indic format "x(1)" no-label
               iro_mtl_tl format "->>>,>>9.99<<<"
               iro_lbr_tl format "->>>,>>9.99<<<"
               iro_bdn_tl format "->>>,>>9.99<<<"
               iro_sub_tl format "->>>,>>9.99<<<"
               iro_mtl_tl + iro_lbr_tl + iro_bdn_tl + iro_sub_tl
                  @ iro_value01
                format "->>>,>>9.99<<<" column-label {&rwrorp04_p_3}
               iro_cost_tot
                   format "->>>,>>9.99<<<" column-label {&rwrorp04_p_2} WITH STREAM-IO /*GUI*/ .
            if last-of (iro_routing) then do:
               down 1 with frame e.
            end.

             end.
          end.
           end.
        end. /*for each pt_mstr*/

        
/*GUI*/ {mfguitrl.i} /*Replace mfrtrail*/

/*GUI*/ {mfgrptrm.i} /*Report-to-Window*/

     end. /*repeat*/

/*K0ZW*/ {wbrp04.i &frame-spec = a}

/*GUI*/ end procedure. /*p-report*/
/*GUI*/ {mfguirpb.i &flds=" site csset part1 part2 part_type show-alts "} /*Drive the Report*/
